package com.zygh.dlqwservice.module.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zygh.dlqwservice.common.constant.EmployeeResponseCodeConst;
import com.zygh.dlqwservice.common.pcdomain.ResponseDTO;
import com.zygh.dlqwservice.module.entity.Jobs;
import com.zygh.dlqwservice.module.mapper.JobsMapper;
import com.zygh.dlqwservice.module.service.IJobsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lee
 * @since 2020-12-24
 */
@Service
public class JobsServiceImpl extends ServiceImpl<JobsMapper, Jobs> implements IJobsService {
    @Resource
    private JobsMapper jobsMapper;

    /**
     * 返回岗位信息
     *
     * @param jobs 封装参数
     * @return List<Jobs>
     */
    @Override
    public List<Jobs> getStation(Jobs jobs) {
        return jobsMapper.getStation(jobs);
    }

    /**
     * 获取岗位下详情
     *
     * @param jobs 封装参数
     * @return List<Jobs>
     */
    @Override
    public List<Jobs> getDetail(Jobs jobs) {
        QueryWrapper<Jobs> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("dept_id", jobs.getDeptId());
        queryWrapper.eq("station", jobs.getStation());
        return jobsMapper.getDetail(queryWrapper);
    }

    @Override
    public ResponseDTO addJobs(Jobs jobs) {
        int insert = jobsMapper.insert(jobs);
        if (insert > 0){
            return ResponseDTO.succ();
        }
        return null;
    }

}
